function startRequest()
{
  tfImieText = document.getElementById('tfImie').value;
  tfNazwiskoText = document.getElementById('tfNazwisko').value;
  if(tfImieText == "" && tfNazwiskoText == ""){
    alert("Prosz wypeni przynajmniej jedno pole.");
    return;
  }
  var btnSzukaj = document.getElementById('btnSzukaj');
  btnSzukaj.disabled = true;
  url = "http://localhost/dane.php?imie=" + tfImieText;
  url += "&nazwisko=" + tfNazwiskoText;
  url = encodeURI(url);
  startGETRequest(url, onComplete, onEnd);
}

function onComplete(text, xml)
{
  var dataDiv = document.getElementById("dataDiv");
  if(text.substr(0, 5) != "error"){
    dataDiv.innerHTML = text;
  }
  else{
    arr = text.split("\n");
    if(arr.length != 2){
      dataDiv.innerHTML = "Bdna odpowied serwera.";
    }
    else{
      dataDiv.innerHTML = arr[1];
    }
  }
}

function onEnd()
{
  var btnSzukaj = document.getElementById('btnSzukaj');
  btnSzukaj.disabled = false;
}